#include <stdio.h>
#define N_MAX 100

int
main ()
{
	char names[N_MAX][10000], surnames[N_MAX][10000];
	int n = 0, i = 0;

	freopen("list.in", "r", stdin);
	freopen("list.out", "w", stdout);

	scanf("%d", &n);

	while (i < n) {
		scanf("%s %s", surnames[i], names[i]);
		++i;
	}

	printf("%d\n", n);
	for (i = 0; i < n; ++i) {
		printf("%s %s\n", names[i], surnames[i]);
	}

	return 0;
}
